// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.core.physics;

import org.joml.Matrix3f;
import org.joml.Matrix4f;
import org.joml.Quaternionf;
import org.joml.Vector3f;

public final class Transform {
    public final Matrix3f basis = new Matrix3f();
    public final Vector3f origin = new Vector3f();

    public Transform() {
    }

    public Transform(Matrix3f matrix3f) {
        this.basis.set(matrix3f);
    }

    public Transform(Matrix4f matrix4f) {
        this.set(matrix4f);
    }

    public Transform(Transform tr) {
        this.set(tr);
    }

    public void set(Transform tr) {
        this.basis.set(tr.basis);
        this.origin.set(tr.origin);
    }

    public void set(Matrix3f matrix3f) {
        this.basis.set(matrix3f);
        this.origin.set(0.0F, 0.0F, 0.0F);
    }

    public void set(Matrix4f matrix4f) {
        matrix4f.get3x3(this.basis);
        matrix4f.getTranslation(this.origin);
    }

    public void transform(Vector3f vector3f) {
        this.basis.transform(vector3f);
        vector3f.add(this.origin);
    }

    public void setIdentity() {
        this.basis.identity();
        this.origin.set(0.0F, 0.0F, 0.0F);
    }

    public void inverse() {
        this.basis.transpose();
        this.origin.negate();
        this.basis.transform(this.origin);
    }

    public void inverse(Transform tr) {
        this.set(tr);
        this.inverse();
    }

    public Quaternionf getRotation(Quaternionf quaternionf) {
        this.basis.getUnnormalizedRotation(quaternionf);
        return quaternionf;
    }

    public void setRotation(Quaternionf quaternionf) {
        this.basis.set(quaternionf);
    }

    public Matrix4f getMatrix(Matrix4f matrix4f) {
        matrix4f.set(this.basis);
        matrix4f.setTranslation(this.origin);
        return matrix4f;
    }

    public boolean equals(Object obj) {
        return obj != null && obj instanceof Transform transform ? this.basis.equals(transform.basis) && this.origin.equals(transform.origin) : false;
    }

    public int hashCode() {
        int _int = 3;
        _int = 41 * _int + this.basis.hashCode();
        return 41 * _int + this.origin.hashCode();
    }
}
